import request from '/@/utils/request';

export function getChildResource(parentId: any) {
	return request({
		url: `/plat/module/${parentId}/childResources`,
		method: 'get',
	});
}

/**
 * 获取租户列表
 * @link 参考：https://api.lmabbe.com/doc.html#/platform/%E7%A7%9F%E6%88%B7%E7%AE%A1%E7%90%86/listUsingGET_2
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function getModuleList(params?: object) {
	return request({
		url: '/plat/module/page',
		method: 'get',
		params,
	});
}

/**
 * 获取租户详情
 * @link 参考：https://api.lmabbe.com/doc.html#/platform/%E7%A7%9F%E6%88%B7%E7%AE%A1%E7%90%86/getByIdUsingGET
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function getModuleResources(moduleId?: any, params?: object) {
	return request({
		url: `/plat/module/${moduleId}/resources`,
		method: 'get',
		params,
	});
}

/**
 * 新增模块信息
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function addModule(params?: object) {
	return request({
		url: '/plat/module',
		method: 'post',
		data: params,
	});
}

/**
 * 修改租户信息
 * @link 参考：https://api.lmabbe.com/doc.html#/platform/%E7%A7%9F%E6%88%B7%E7%AE%A1%E7%90%86/updateUsingPUT
 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function editModule(params?: object) {
	return request({
		url: `/plat/module`,
		method: 'put',
		data: params,
	});
}

export function getModuleDetail(moduleId?: any) {
	return request({
		url: `/plat/module/${moduleId}`,
		method: 'get',
	});
}

export function delModule(dicId?: any) {
	return request({
		url: `/plat/module/${dicId}`,
		method: 'delete',
	});
}

export function addModuleResource(moduleId: any, params?: object) {
	return request({
		url: `/plat/module/${moduleId}/resource`,
		method: 'post',
		data: params,
	});
}

export function getModuleResourceDetail(resourceId?: any) {
	return request({
		url: `/plat/module/resource/${resourceId}`,
		method: 'get',
	});
}

export function editModuleResourceDetail(moduleId: String, resourceId: any, params: object) {
	return request({
		url: `/plat/module/${moduleId}/resource/${resourceId}`,
		method: 'put',
		data: params,
	});
}

export function delModuleResource(moduleId: any) {
	return request({
		url: `/plat/module/resource/${moduleId}`,
		method: 'delete',
	});
}

export function getAllDictTree(params?: object) {
	return request({
		url: '/plat/module/allTree',
		method: 'get',
		params,
	});
}

export function getAllModuleTree(params?: object) {
	return request({
		url: '/plat/module/allTree',
		method: 'get',
		params,
	});
}
